/*
 * Saphre - Suffix Arrays for Phrase Extraction
 * Copyright (C) 2013 
 * Dale Gerdemann - Tübingen, Germany 
 * Niko Schenk - Frankfurt am Main, Germany
 * All rights reserved.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */
package saphre.demo;

import saphre.commands.CmdRepeats;
import saphre.commands.CmdRepeatsParameters;
import saphre.core.SaphreBase;

/**
 * A simple client program to SAPHRE.
 *
 * Illustrates how to:
 *
 * 1. Specify a corpus 
 * 2. Generate the suffix array and its components. 
 * 3. Run a command on the corpus data (extraction of repeats)
 *
 * @author Niko Schenk
 */
public class SimpleSuffixArrayDemo {

    // Project path.
    public static final String PROJECT_PATH = "corpora/";
    
    /**
     * Demo client.
     *
     * @param args
     */
    public static void main(String[] args) {

        // Corpus name.
        String corpusName = "testcorpus";
        
        // Set up SaphreBase object with pointers to regex, normalizer,
        // and boundary symbols.
        SaphreBase saphreBase = new SaphreBase(null,
                PROJECT_PATH + corpusName + "/corpus/", // corpus data
                PROJECT_PATH + corpusName + "/loadOptions/regex", // regex
                PROJECT_PATH + corpusName + "/loadOptions/norm", // normalizer
                PROJECT_PATH + corpusName + "/loadOptions/boundary", // boundaries
                true, null);

        // Generate suffix array and components and
        // serialize data files.
        saphreBase.invoke();

        // Find repeated n-grams - set parameter values first.
        CmdRepeatsParameters repeatsParameters = new CmdRepeatsParameters();
        // Search for all n-grams containing the word "test".
        repeatsParameters.setContainsTerm("test");
        repeatsParameters.setWriteToFile(false);
        // Execute repeats command.
        CmdRepeats cmdRepeatsCommand = new CmdRepeats();
        cmdRepeatsCommand.extractRepeats(saphreBase, repeatsParameters);
    
    }
}
